<% add_decidim_page_title(t(".preview")) %>
<div class="item_show__header">
  <h1 class="item_show__header-title !w-1/2">
    <%= t ".preview" %>
  </h1>
  <div class="flex ml-auto items-center gap-x-4">
    <% if allowed_to?(:update, :newsletter, newsletter: @newsletter) %>
      <%= link_to t(".send_me_a_test_email"), send_to_user_newsletter_path(@newsletter), class: "button button__sm button__secondary hollow", method: :post %>
    <% end %>
    <% unless @newsletter.sent? %>
      <%= link_to t("actions.edit", scope: "decidim.admin"), [:edit, @newsletter], class: "button button__sm button__secondary" %>
    <% end %>
  </div>
</div>
<div class="item__edit-form">
  <div class="card">
    <div class="card-section">
      <dl>
        <dt class="font-bold"><%= t ".subject" %></dt>
        <dd><%= @email.subject %></dd>
        <dt class="font-bold"><%= t("models.newsletter.fields.sent_to", scope: "decidim.admin") %></dt>
        <dd><%= selective_newsletter_to newsletter %></dd>
      </dl>
      <iframe src="<%= preview_newsletter_path(@newsletter) %>" class="w-full h-[60lvh]" data-email-preview>
      </iframe>
    </div>
  </div>
  <div class="item__edit-sticky">
    <div class="item__edit-sticky-container">
      <% if allowed_to?(:update, :newsletter, newsletter: @newsletter) %>
        <% unless @newsletter.sent? %>
          <%= link_to t(".select_recipients_to_deliver"), select_recipients_to_deliver_newsletter_path(@newsletter), class: "button button__sm button__secondary alert" %>
        <% end %>
      <% end %>
    </div>
  </div>
</div>
